package com.martin.study.mybatis.original;


import com.martin.study.mybatis.original.mapper.UserMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import sun.misc.Resource;

import java.io.IOException;
import java.io.InputStream;

public class MybatisBootstrap {
	public static void main(String[] args) throws IOException {
		InputStream inputStream = Resources.getResourceAsStream("mybatis.xml");
		SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
		try (SqlSession session = sqlSessionFactory.openSession()) {
			System.out.println(session);
			session.getConfiguration().addMapper(UserMapper.class);
			UserMapper mapper = session.getMapper(UserMapper.class);
			System.out.println(mapper.selectOne());
		}
	}
}
